<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <style>
        ul{
            list-style-type: none;
        }
        li{
            float: left;
        }
    </style>
    <script src="../js/jquery.min.js"></script>
</head>
<body>
<script>
        $.ajax({
            url:"/name",
            type:"post",
            datatype:"json",
            success:function (data) {
                $(".welcome")[0].innerHTML=data+"欢迎你";
            },
            error:function (data) {
                alert("出错了!~")
            }
        });


        /*Cookie代码
        function setCookie(cname,cvalue,exdays){
            var d = new Date();
            d.setTime(d.getTime()+(exdays*24*60*60*1000));
            var expires = "expires="+d.toGMTString();
            document.cookie = cname+"="+cvalue+"; "+expires;
        }
        function getCookie(cname){
            var name = cname + "=";
            var ca = document.cookie.split(';');
            for(var i=0; i<ca.length; i++) {
                var c = ca[i].trim();
                if (c.indexOf(name)==0) { return c.substring(name.length,c.length); }
            }
            return "";
        }
        function checkCookie(){
            var user=getCookie("username");
            if (user!=""){
                alert("欢迎 " + user + " 再次访问");
            }
            else {
                user = prompt("请输入你的名字:","");
                if (user!="" && user!=null){
                    setCookie("username",user,30);
                }
            }
        }*/
</script>
<ul class="new">
    <li>博客</li>
    <li><a href="/add">新建博客</a></li>
    <li>
        <input type="text"/>
        <input type="submit" value="提交"/>
    </li>
    <li class="welcome">欢迎您:</li>
    <li id="login">切换账号</li>
</ul>

<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>博客标题</th>
                    <th>博客描述</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="tbody">
                <!--<tr class="success"></tr>
                <tr class="error"></tr>
                <tr class="warning"></tr>
                <tr class="info"></tr>-->
                </tbody>
                </table>
            <div class="pagination pagination-right">
                <ul>
                    <li>
                        <a href="#">上一页</a>
                    </li>
                    <li>
                        <a href="#">1</a>
                    </li>
                    <li>
                        <a href="#">2</a>
                    </li>
                    <li>
                        <a href="#">3</a>
                    </li>
                    <li>
                        <a href="#">4</a>
                    </li>
                    <li>
                        <a href="#">5</a>
                    </li>
                    <li>
                        <a href="#">下一页</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
</body>
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script>
    $.ajax({
        url:"/select",
        type:"post",
        datatype:"json",
        success: function (datas) {
            for (var i in datas) {
                var msg = datas[i];
                $("<tr><td>" + msg.title + "</td><td>"+msg.des+"</td><td><a href='/del'>删除</a></td></tr>").appendTo($("#tbody"));
            }
        },
        error:function (datas) {
            alert("出错了!~")
        }
    });
</script>
<script>
    $("#login").click(function () {
        window.location.href="/login";
    });
</script>
</html>